/**
 * 系统图标定义
 * 完全使用 react-icons，不依赖 emoji
 */

import React from 'react';
import { 
  FaPlay, 
  FaCircleCheck, 
  FaCircleXmark, 
  FaStop, 
  FaBell,
  FaClock,
  FaCalendar,
  FaTriangleExclamation,
} from 'react-icons/fa6';

// 系统图标类型枚举
export const SYSTEM_ICONS = {
  RUN_START: 'run-start',
  RUN_SUCCESS: 'run-success', 
  RUN_ERROR: 'run-error',
  RUN_STOP: 'run-stop',
  SYSTEM_INFO: 'system-info',
  DURATION: 'duration',
  TIMESTAMP: 'timestamp',
  WARNING: 'warning',
  ERROR: 'error'
};

// 图标类型到组件的映射
export const ICON_COMPONENTS = {
  [SYSTEM_ICONS.RUN_START]: FaPlay,
  [SYSTEM_ICONS.RUN_SUCCESS]: FaCircleCheck,
  [SYSTEM_ICONS.RUN_ERROR]: FaCircleXmark,
  [SYSTEM_ICONS.RUN_STOP]: FaStop,
  [SYSTEM_ICONS.SYSTEM_INFO]: FaBell,
  [SYSTEM_ICONS.DURATION]: FaClock,
  [SYSTEM_ICONS.TIMESTAMP]: FaCalendar,
  [SYSTEM_ICONS.WARNING]: FaTriangleExclamation,
  [SYSTEM_ICONS.ERROR]: FaCircleXmark
};

// 渲染系统图标
export const renderSystemIcon = (iconType, className = '', props = {}) => {
  const IconComponent = ICON_COMPONENTS[iconType] || FaBell;
  return <IconComponent className={className} {...props} />;
};

// 根据消息内容推断图标类型
export const getIconTypeFromMessage = (message) => {
  const lowerMessage = message.toLowerCase();
  
  if (lowerMessage.includes('开始运行') || lowerMessage.includes('run start')) {
    return SYSTEM_ICONS.RUN_START;
  }
  if (lowerMessage.includes('运行结束') || lowerMessage.includes('run end') || lowerMessage.includes('成功')) {
    return SYSTEM_ICONS.RUN_SUCCESS;
  }
  if (lowerMessage.includes('错误') || lowerMessage.includes('error') || lowerMessage.includes('失败')) {
    return SYSTEM_ICONS.RUN_ERROR;
  }
  if (lowerMessage.includes('停止') || lowerMessage.includes('stop')) {
    return SYSTEM_ICONS.RUN_STOP;
  }
  if (lowerMessage.includes('警告') || lowerMessage.includes('warning')) {
    return SYSTEM_ICONS.WARNING;
  }
  
  return SYSTEM_ICONS.SYSTEM_INFO;
};
